Buckhorn Cholla, Cylindropuntia acanthocarpa
Silver Cholla, Cylindropuntia echinocarpa
Beavertail, Opuntia basilaris
head(cholla) #see a bit of the data
## # A tibble: 6 x 23
## transect transect_start_~ transect_start_~ transect_end_lat
## <int> <dbl> <dbl> <chr>
## 1 1 34.8 116. 34.78203
## 2 1 34.8 116. 34.78203
## 3 1 34.8 116. 34.78203
## 4 1 34.8 116. 34.78203
## 5 1 34.8 116. 34.78203
## 6 1 34.8 116. 34.78203
## # ... with 19 more variables: transect_end_lon <chr>, meter <int>,
## # cactus_id <chr>, cactus_number <chr>, species <chr>,
## # distance_meters <dbl>, x <dbl>, y <dbl>, z <dbl>, primary <int>,
## # secondary <int>, tertiary <int>, quaternary <int>, health_index <int>,
## # cactus_lat <dbl>, cactus_lon <dbl>, shrub_present <chr>,
## # shrub_alive <chr>, species_letter <chr>
head(opuntia) #and for opuntia
## # A tibble: 6 x 14
## cactus_id species x y z primary secondary tertiary quaternary
## <int> <chr> <dbl> <dbl> <dbl> <int> <int> <int> <int>
## 1 1 Opunti~ 0.15 0.15 0.15 13 1 0 0
## 2 2 Opunti~ 0.3 0.4 0.2 24 3 0 0
## 3 3 Opunti~ 0.2 0.3 0.2 11 4 0 0
## 4 4 Opunti~ 0.2 0.2 0.1 5 3 0 0
## 5 5 Opunti~ 0.1 0.15 0.1 6 0 0 0
## 6 6 Opunti~ 0.4 0.4 0.15 11 35 6 0
## # ... with 5 more variables: health_index <int>, cactus_lat <dbl>,
## # cactus_lon <dbl>, shrub_present <chr>, shrub_alive <chr>
map <- leaflet() %>%
addTiles() %>%
addCircleMarkers(lng = -115.663, lat = 34.783, radius = 5, color = "#F4D99C", popup = "Sunset Cove") %>% #map center point for Sunset Cove
addCircleMarkers(lng = buckhorn$cactus_lon, lat = buckhorn$cactus_lat, radius = 5, color = "#D5DEAF", popup = "Buckhorn Cholla") %>% #Map buckhorn
addCircleMarkers(lng = silver$cactus_lon, lat = silver$cactus_lat, radius = 5, color = "#AFCEDE", popup = "Silver Cholla") %>% #map silver
addCircleMarkers(lng=opuntia$cactus_lon, lat = opuntia$cactus_lat, radius = 5, color = "#DEAFD6") #add opuntia
map #print
library("ggmap")
species <- all$species
cali <- get_map(location = c(lon = -115.662, lat = 34.7825), zoom = 17, color="bw")
## Source : https://maps.googleapis.com/maps/api/staticmap?center=34.7825,-115.662&zoom=17&size=640x640&scale=2&maptype=terrain&language=en-EN&key=xxx
sunset <- ggmap(cali)
sunset <- sunset +
geom_point(data=all, aes(x=cactus_lon, y=cactus_lat, colour=species, group=species), alpha = 3/10, size = 4) +
labs(title = "A", x = "longitude", y = "latitude", color = "Species")
sunset
cali2 <- get_map(location = c(lon = -115.663, lat = 34.7825), zoom = 19, color="bw")
## Source : https://maps.googleapis.com/maps/api/staticmap?center=34.7825,-115.663&zoom=19&size=640x640&scale=2&maptype=terrain&language=en-EN&key=xxx
sunset2 <- ggmap(cali2)
sunset2 <- sunset2 +
geom_point(data=all, aes(x=cactus_lon, y=cactus_lat, colour=species, group=species), alpha = 3/10, size = 4) +
labs(title = "B", x = "longitude", y = "latitude", color = "Species")
sunset2
tapply(all$z, all$species, mean) #means height of each species
## Cylindropuntia anthrocarpa Cylindropuntia echinocarpa
## 1.0380952 0.5529592
## Opuntia basilaris
## 0.1673077
ggplot(all, aes(x = species, y=z)) +
geom_boxplot() + labs(title = "Size of Cacti", x = "Species", y = "Height in meters") +
theme_minimal() #no outliers
#Test for statistical difference between species
shapiro.test(buckhorn$z) #nearly normal
##
## Shapiro-Wilk normality test
##
## data: buckhorn$z
## W = 0.97717, p-value = 0.06667
shapiro.test(silver$z) #not normal
##
## Shapiro-Wilk normality test
##
## data: silver$z
## W = 0.98532, p-value = 0.349
shapiro.test(opuntia$z) #normal
##
## Shapiro-Wilk normality test
##
## data: opuntia$z
## W = 0.88797, p-value = 0.008519
#Because not everything is normal, let's do a non parametric version of ANOVA: Kruskall Wallis to test height of cacti
kruskal.test(species ~ z, data = all)
##
## Kruskal-Wallis rank sum test
##
## data: species by z
## Kruskal-Wallis chi-squared = 151.52, df = 52, p-value = 1.158e-11
#p < 0.0001, each cactus species has non-indentical heights.
#Buckhorn Cholla size distribution
ggplot(buckhorn, aes(x = z)) +
geom_density() + labs(title = "Size of Cacti: Buckhorn", x = "Height", y = "Cacti") +
theme_minimal() #bimodal, ever so slightly
ggplot(silver, aes(x = z)) +
geom_density() + labs(title = "Size of Cacti: Silver", x = "Height", y = "Cacti") +
theme_minimal() #unimodal
ggplot(opuntia, aes(x = z)) +
geom_density() + labs(title = "Size of Cacti: Beavertail", x = "Height", y = "Cacti") +
theme_minimal()
#Determine equal-sized size classes for cacti based on height (z)
minmax <- data.frame(
aggregate(z~species, data=all, min),
aggregate(z~species, data=all, max)) #create dataframe with min and max
bins <- mutate(minmax, range = z.1-z)
bins <- mutate(bins, bins = range/3) #divide by 3 (because 3 size classes wanted, small medium and large) to get differences between size classes
size_class_options <- mutate(bins, small = z) %>%
mutate(bins, medium = z + bins) %>%
mutate(bins, large = z.1 - bins) #create our size classes, each column represents the minimum value to start each size class.
#Make it pretty
#create vectors
species <- c("Cylindropuntia acanthocarpa", "Cylindropuntia echinocarpa", "Opuntia basilaris")
small <- c("<85cm", "<45cm", "<15cm")
medium <- c("86cm - 152cm", "46cm - 72cm", "16cm - 22cm")
large <- c(">153cm", ">73cm", ">23cm")
#create dataframe for easy viewing
size_class <- data.frame(species, small, medium, large)
size_class
## species small medium large
## 1 Cylindropuntia acanthocarpa <85cm 86cm - 152cm >153cm
## 2 Cylindropuntia echinocarpa <45cm 46cm - 72cm >73cm
## 3 Opuntia basilaris <15cm 16cm - 22cm >23cm
#Let's quickly visualize the size bins
ggplot(size_class_options, aes(x = species, y=bins)) +
geom_bar(stat = "identity") + labs(title = "Size of Bins", x = "Species", y = "Bins size (meters)") +
theme_minimal()
#What is the distribution of health index scores?
ggplot(all, aes(x = health_index)) +
geom_histogram() + labs(title = "Number of individuals in each health class", x = "Heath of Species", y = "Health class") +
facet_grid(~species) +
theme_minimal()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
The Study Site, Sunset Cove